
<table class="soft-list" data-page="${page}" data-page-size="${pageSize}" data-count="${count}">
	<tr class="title-row">
		<th class="text-center" width="50">序号</th>
		<th class="text-center">名称</th>
		<th class="text-center">版本</th>
		<th class="text-center">上传时间</th>
	</tr>
	<#if data??> <#list data as d>
	<tr data-id="${d.id}">
		<td class="text-center">${d_index+1}</td>
		<td class="text-center">${d.name}</td>
		<td class="text-center">${d.version}</td>
		<td class="text-center">${d.upTime}</td>
	</tr>
	</#list> </#if>
</table>

<script src="${request.contextPath}/core/js/jquery.form.js"></script>
<script src="${request.contextPath}/js/suredy-list.js"></script>
<script src="${request.contextPath}/js/suredy-modal.js"></script>
<script src="${request.contextPath}/app/js/form-checker.js"></script>
<script type="text/javascript">
	$(function() {
		$('.soft-list').list({
			search : false,
			checkbox : true,
			paginate : function(page, pageSize, key) {
				$.suredy.loadConent('${request.contextPath}/software/manage?page=' + page + '&pageSize=' + pageSize);
			},
			btns : [ {
				text : '新增',
				style : 'btn-success',
				click : function() {
					$.suredy.showModal({
						uri : '${request.contextPath}/app/software/upload-file.html',
						okClick : function() {
							var form = $('form.upload-file-form');

							if (!$.suredy.formChecker(form)) {
								return false;
							}

							form.ajaxSubmit({
								url : '${request.contextPath}/software/upload',
								dataType : 'json',
								success : function(data, textStatus, jqXHR) {
									if (!data) {
										alert('上传文件失败！');
										return false;
									}

									$.suredy.closeModal();

									$.suredy.loadContent('${request.contextPath}/software/manage');
								},
								error : function(jqXHR, textStatus, errorThrown) {
									alert('上传文件失败！！\n' + errorThrown);
									return false;
								}
							});
						}
					});
				}
			}, {
				text : '删除',
				style : 'btn-danger',
				click : function() {
					if (!window.confirm('确认删除选中的软件么？')) {
						return false;
					}

					var trs = $.suredy.list.checked($('.soft-list'));
					var ids = [];

					trs.each(function(i) {
						ids[ids.length] = $(this).data('id');
					});

					$.ajax({
						url : '${request.contextPath}/software/delete',
						data : {
							ids : ids
						},
						type : 'post',
						dataType : 'json',
						traditional : true,
						success : function(data, textStatus, jqXHR) {
							if (!data) {
								alert('删除失败！');
								return false;
							}

							$.suredy.loadContent('${request.contextPath}/software/manage');
						},
						error : function(jqXHR, textStatus, errorThrown) {
							alert('删除失败！！\n' + errorThrown);
							return false;
						}
					});
				}
			} ]
		});
	});
</script>
